package main

import (
	"context"
	"flag"
	"github.com/zeromicro/go-zero/core/logx"
	"os"
	"t-go-zero/service/asynq/server/internal/config"
	handle "t-go-zero/service/asynq/server/internal/handler"
	"t-go-zero/service/asynq/server/internal/svc"

	"github.com/zeromicro/go-zero/core/conf"
)

var configFile = flag.String("f", "etc/asynq-server.yaml", "the config file")

func main() {
	flag.Parse()

	var c config.Config
	conf.MustLoad(*configFile, &c)

	// 中间件注册
	svcContext := svc.NewServiceContext(c)

	// 创建上下文
	ctx := context.Background()

	// 注册asymon的服务
	cronJob := handle.NewCronJob(ctx, svcContext)

	mux := cronJob.Register()

	if err := svcContext.AsynqServer.Run(mux); err != nil {
		logx.Errorf("!!!CronJobErr!!! run err:%+v", err)
		os.Exit(1)
	}

}
